Access to basic sanitation facilities in schools is a critical indicator of global development and children’s rights. It reflects a nation’s ability to support the health, well-being, and educational outcomes of its future generations. Sanitation goes beyond the provision of toilets to include clean water, handwashing facilities, and hygienic waste management systems. Schools lacking basic sanitation face higher absenteeism rates, especially among girls, and contribute to the spread of communicable diseases, undermining broader development goals.
Globally, millions of children attend schools that lack even basic sanitation services. While substantial progress has been made through initiatives like the Millennium Development Goals (MDGs) and Sustainable Development Goals (SDGs), gaps remain across regions and countries. This report uses UNICEF datasets to investigate the proportion of schools with basic sanitation services, uncover disparities, and explore socio-economic factors that correlate with sanitation access.
Dataset Overview
This study combines two rich datasets to provide a multi-dimensional analysis:
unicef_indicator_1.csv: Contains quantitative data on the proportion of schools with basic sanitation services, offering a direct view into sanitation access globally.
unicef_metadata.csv: Includes critical country-level socio-economic indicators such as GDP per capita, population totals, Gross National Income (GNI), life expectancy, and inflation rates.
Merging these datasets enables a comprehensive assessment of how macroeconomic conditions influence sanitation outcomes in education. Key variables analyzed include sanitation access rates, economic indicators, demographic trends, and health infrastructure.
Top 10 Countries: Highest School Sanitation Access
Interactive Bar Chart
Figure 2
Global Sanitation Distribution
Choropleth World Map
Figure 3
Global Trend: School Sanitation
Scatter Plot with Linear Regression
Figure 4
Global Time Series Trends
Line Plot
Figure 5
Global Snapshot: GDP vs Sanitation Access
Scatter Plot with Trendline
Top 10 Countries: Highest School Sanitation Access (Interactive Bar Chart)
This bar chart highlights the leading countries achieving nearly universal basic sanitation in schools. Interactive bar charts allow quick comparisons between countries and spotlight those that exemplify best practices.
Show Code
import plotly.express as px# STEP 1: Take latest sanitation year per countrylatest_data = full_data_pd.sort_values(['Country', 'Year'], ascending=[True, False]).drop_duplicates('Country')# STEP 2: Drop rows with missing sanitation value (Value = NaN)latest_data = latest_data.dropna(subset=["Value"])# STEP 3: Optional: Remove countries where sanitation is exactly 100% (for variation)latest_data = latest_data[latest_data["Value"] <100]# STEP 4: Sort and pick Top 10top10_countries = latest_data.sort_values("Value", ascending=False).head(10)# STEP 5: Create an interactive bar chartfig = px.bar( top10_countries, x="Value", y="Country", orientation="h", color="Value", # Color by sanitation % color_continuous_scale="Blues", title="Top 10 Countries: Schools with Basic Sanitation Services ", labels={"Value": "Sanitation (%)", "Country": "Country"}, hover_data=["Population, total", "GDP per capita (constant 2015 US$)", "Life expectancy at birth, total (years)"])fig.show()
Insight: Countries like Monaco, Luxembourg, and Singapore show exceptional sanitation coverage, correlating with high GDP per capita and strong educational policies. These examples can guide strategic interventions in lower-performing nations.
Global Sanitation Distribution (Choropleth World Map)
The choropleth map provides a visual overview of how sanitation services are distributed globally. Such maps enable spatial analysis and quickly reveal regional disparities.
Show Code
import plotly.express as px# STEP 1: Prepare latest sanitation datalatest_map_data = full_data_pd.sort_values(['Country', 'Year'], ascending=[True, False]).drop_duplicates('Country')# STEP 2: Drop missing sanitation valueslatest_map_data = latest_map_data.dropna(subset=["Value"])# STEP 3: Create the Choropleth Mapfig = px.choropleth( latest_map_data, locations="Country", locationmode="country names", color="Value", hover_name="Country", hover_data={"Value": True,"Population, total": True,"GDP per capita (constant 2015 US$)": True,"Life expectancy at birth, total (years)": True }, color_continuous_scale="Viridis", title="World Map: Proportion of Schools with Basic Sanitation Services ", labels={"Value": "Sanitation (%)"})# Beautify the map layoutfig.update_layout( geo=dict( showland=True, landcolor="LightGray", showocean=True, oceancolor="LightBlue", ))# Show the mapfig.show()
Insight: High sanitation access in Europe, North America, and parts of East Asia contrasts sharply with significant deficits in Sub-Saharan Africa, South Asia, and conflict-affected regions. These visual disparities highlight where international support and development efforts should prioritize.
Global Trend: School Sanitation (Scatter Plot with Linear Regression)
This scatter plot examines the association between national wealth and school sanitation access. The linear regression line quantifies the strength and direction of this relationship.
Show Code
import plotly.express as px# We'll use full_data_pd directly# STEP 1: Drop missing sanitation valuesscatter_data = full_data_pd.dropna(subset=["Value"])# STEP 2: Create the scatter plotfig = px.scatter( scatter_data, x="Year", y="Value", color="GNI (current US$)", # Color points by GNI hover_name="Country", trendline="ols", # Add regression line color_continuous_scale="Viridis", # <<< Use same Viridis color scale title="Global Trend: Schools with Basic Sanitation Services Over Years ", labels={"Year": "Year","Value": "Sanitation (%)","GNI (current US$)": "GNI (Current USD)" })# Show the plotfig.show()